﻿// 功能：
// 描述：
// 作者：温伟鹏
// 日期：2010/5/25 20:36:39

using System;
using MeizuSDK.Presentation;

namespace Demo
{
    class ScrollableWindow : DemoWindowBase
    {
        private TrackBar trackBar;
        private Label lblTrackValue;
        private HeadingBar headingBar;
        private ScrollableControl scrollablePanel;
        private CheckBoxList checkBoxList;

        public ScrollableWindow()
        {
            scrollablePanel = new ScrollableControl();
            scrollablePanel.Size = new System.Drawing.Size(Width, Height - ToolBar.HEIGHT);
            scrollablePanel.VScroll = true;// 启用垂直滚动条
            scrollablePanel.Location = new System.Drawing.Point(0, 0);

            Controls.Add(scrollablePanel);

            headingBar = new HeadingBar();
            headingBar.Location = new System.Drawing.Point(0, 0);
            headingBar.Text = "俺是Heading Bar";

            trackBar = new TrackBar();
            trackBar.Height = 50;
            trackBar.Width = 300;
            trackBar.Location = new System.Drawing.Point(0, headingBar.Height);
            trackBar.ValueChanged += new EventHandler(trackBar_ValueChanged);

            lblTrackValue = new Label();
            lblTrackValue.Size = new System.Drawing.Size(100, 50);
            lblTrackValue.Location = new System.Drawing.Point(320, headingBar.Height);
            lblTrackValue.Text = string.Format("{0}%", trackBar.Value);

            checkBoxList = new CheckBoxList();
            checkBoxList.Size = new System.Drawing.Size(Width, 70);
            checkBoxList.Location = new System.Drawing.Point(0, 100);

            for (int i = 0; i < 200; i++)
            {
                ListItem item = new ListItem("列表项_~!@#$%^&*()_+_" + (i + 1).ToString(), null);

                checkBoxList.Items.Add(item);
            }

            scrollablePanel.Controls.Add(headingBar);
            scrollablePanel.Controls.Add(trackBar);
            scrollablePanel.Controls.Add(lblTrackValue);
            scrollablePanel.Controls.Add(checkBoxList);

            toolbar.SetMiddleButton(true, true, "消息", null, null, null);
        }

        void trackBar_ValueChanged(object sender, EventArgs e)
        {
            lblTrackValue.Text = string.Format("{0}%", trackBar.Value);
        }

        protected override void toolbar_ButtonClick(object sender, ToolBar.ButtonEventArgs e)
        {
            base.toolbar_ButtonClick(sender, e);

            if (e.Index == ToolBarButtonIndex.MiddleTextButton)
            {
                MessageBox.Show(string.Format("您选择了[{0}]个列表项", checkBoxList.SelectedItems.Length), "消息");
            }
        }
    }
}
